package com.gxa.employment.entity.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
 * 系统权限表
 *
 * @author xdr
 * @since 2025-03-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("tb_permission")
public class Permission implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 权限ID
     */
    @TableId(value = "perm_id", type = IdType.AUTO)
    private Integer permId;

    /**
     * 权限名称
     */
    @TableField("perm_name")
    private String permName;

    /**
     * 权限对应的url
     */
    @TableField("perm_url")
    private String permUrl;

    /**
     * 权限备注
     */
    @TableField("perm_remark")
    private String permRemark;

    /**
     * 权限类型
     */
    @TableField("perm_type")
    private String permType;

    /**
     * 父级ID
     */
    @TableField("perm_pid")
    private Integer permPid;

    /**
     * 创建时间
     */
    @TableField("perm_created")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime permCreated;

    /**
     * 创建时间
     */
    @TableField("created")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime created;

    /**
     * 更新时间
     */
    @TableField("updated")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime updated;

    /**
     * 逻辑删除标识
     */
    @TableField("deleted")
    private Boolean deleted;

    /**
     * 子权限列表
     */
    @TableField(exist = false)
    private List<Permission> children=new ArrayList<>();
}
